﻿using System.IO;
using System.Reflection;
using mmCrypt;

namespace mmUI.Managers
{
    public class Config
    {
        public const string AppVersion = "0.53";

        public static bool SavePassword
        {
            get { return Properties.Settings.Default.savePassword; }
            set
            {
                Properties.Settings.Default.savePassword = value;
                Properties.Settings.Default.Save();
            }
        }

        public static string Password
        {
            get
            {
                var ac = new AesCrypt();
                return ac.DecryptString(Properties.Settings.Default.password);
            }
            set
            {
                var ac = new AesCrypt();
                Properties.Settings.Default.password = ac.EncryptToString(value);
                Properties.Settings.Default.Save();
            }
        }

        public static string CoverDir
        {
            get { return Properties.Settings.Default.coverDir; }
            set { Properties.Settings.Default.coverDir = value; Properties.Settings.Default.Save(); }
        }

        public static string FilestubeArg
        {
            get { return Properties.Settings.Default.filestubeArg; }
            set { Properties.Settings.Default.filestubeArg = value; Properties.Settings.Default.Save(); }
        }

        public static string JdownloaderExe
        {
            get { return Properties.Settings.Default.jdownloaderExe; }
            set { Properties.Settings.Default.jdownloaderExe = value; Properties.Settings.Default.Save(); }
        }

        public static string GoogleLogin
        {
            get { return Properties.Settings.Default.gmail; }
            set { Properties.Settings.Default.gmail = value; Properties.Settings.Default.Save(); }
        }

        public static bool ShowUpdatesNotifications
        {
            get { return Properties.Settings.Default.updatesNotifications; }
            set
            {
                Properties.Settings.Default.updatesNotifications = value;
                Properties.Settings.Default.Save();
            }
        }

        public static ProviderType ProviderType
        {
            get
            {
                return Properties.Settings.Default.providerType;
            }
            set { Properties.Settings.Default.providerType = value; Properties.Settings.Default.Save(); }
        }

        public static string AppDir
        {
            get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
        }

        public static void PrepareFolders()
        {
            var coversDir = Path.Combine(AppDir, CoverDir);
            if(!Directory.Exists(coversDir))
            {
                Directory.CreateDirectory(coversDir);
            }
        }
    }
}
